<?php 

namespace Acme\CommonBundle\Form\CustomFieldType;
 
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilder;
use Acme\CommonBundle\Form\DataTransformer\UniversityToIdTransformer;
use Doctrine\Common\Persistence\ObjectManager;

class UniversitySelectorType extends AbstractType
{
	private $om;

    public function __construct(ObjectManager $om)
    {
        $this->om = $om;
    }

    public function buildForm(FormBuilder $builder, array $options)
    {
        $transformer = new UniversityToIdTransformer($this->om);
        $builder->appendClientTransformer($transformer);
    }

    public function getDefaultOptions(array $options)
    {
        return array(
            'invalid_message' => '所选大学不存在',
        	'label' => '所在大学',
        );
    }

    public function getParent(array $options)
    {
        return 'text';
    }

    public function getName()
    {
        return 'university_selector';
    }
}